package com.hzmg.worker.autoconfigure;

import com.hzmg.akkacloud.common.RemoteConstant;
import com.hzmg.akkacloud.worker.common.constants.StoreStrategy;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;

/**
 * AkkaCloud properties configuration class.
 *
 * @author zbw
 * @since 2022/7/9
 */
@ConfigurationProperties(prefix = "akkacloud")
public class AkkaCloudProperties {

    private final Worker worker = new Worker();

    public Worker getWorker() {
        return worker;
    }

    /**
     * AkkaCloud worker configuration properties.
     */
    @Setter
    @Getter
    public static class Worker {
        /**
         * Name of application, String type. Total length of this property should be no more than 255
         * characters. This is one of the required properties when registering a new application. This
         * property should be assigned with the same value as what you entered for the appName.
         */
        private String appName;
        /**
         * Akka port of AkkaCloud-worker, optional value. Default value of this property is 27777.
         * If multiple AkkaCloud-worker nodes were deployed, different, unique ports should be assigned.
         */
        private int akkaPort = RemoteConstant.DEFAULT_WORKER_PORT;
        /**
         * Address(es) of AkkaCloud-server node(s). Ip:port or domain.
         * Example of single AkkaCloud-server node:
         * <p>
         * 127.0.0.1:7700
         * </p>
         * Example of AkkaCloud-server cluster:
         * <p>
         * 192.168.0.10:7700,192.168.0.11:7700,192.168.0.12:7700
         * </p>
         */
        private String serverAddress;
        /**
         * UserRole(s) is the actorSystem role identification of the cluster .
         * It is used as an accurate identification of routers
         */
        private String userRole;
        /**
         * Local store strategy for H2 database. {@code disk} or {@code memory}.
         */
        private StoreStrategy storeStrategy = StoreStrategy.DISK;
        /**
         * Max length of response result. Result that is longer than the value will be truncated.
         */
        private int maxResultLength = 8192;
        /**
         * If test mode is set as true, AkkaCloud-worker no longer connects to the server or validates appName.
         * Test mode is used for conditions that your have no akkacloud-server in your develop env so you can't startup the application
         */
        private boolean enableTestMode = false;
        /**
         * Max length of appended workflow context value length. Appended workflow context value that is longer than the value will be ignore.
         */
        private int maxAppendedWfContextLength = 8192;

    }
}
